package com.gongzhiyun.springboot3test.vo;

import com.gongzhiyun.springboot3test.entity.user.TbRole;
import com.gongzhiyun.springboot3test.entity.user.TbUser;
import com.gongzhiyun.springboot3test.entity.user.TbUserExinfo;
import com.gongzhiyun.springboot3test.entity.user.TbUserInfo;
import lombok.Data;
import org.apache.catalina.User;

import java.io.Serial;
import java.io.Serializable;

@Data
public class UserInfo implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    private TbUser user;
    private TbUserInfo userInfo;
    private TbRole role;
    private TbUserExinfo exinfo;
    private String lastWord;
    private Integer UnreadCount;

    public UserInfo viewData(){
        UserInfo info=new UserInfo();
        if (user!=null){
            TbUser tbUser=new TbUser();
            tbUser.setUid(user.getUid());
            tbUser.setUsername(user.getUsername());
            tbUser.setRole(user.getRole());
            tbUser.setLastupdate(user.getLastupdate());
            info.setUser(tbUser);

        }
        if (userInfo!=null){
            TbUserInfo tbUserInfo=new TbUserInfo();
            tbUserInfo.setNickname(userInfo.getNickname());
            tbUserInfo.setSex(userInfo.getSex());
            tbUserInfo.setQq(userInfo.getQq());
            tbUserInfo.setWechat(userInfo.getWechat());
            tbUserInfo.setEmail(userInfo.getEmail());
            tbUserInfo.setPhone(userInfo.getPhone());
            tbUserInfo.setInfo(userInfo.getInfo());
            tbUserInfo.setLastupdate(userInfo.getLastupdate());
            info.setUserInfo(tbUserInfo);
        }
        if (role!=null){
            TbRole tbRole=new TbRole();
            tbRole.setRoleName(role.getRoleName());
            info.setRole(tbRole);
        }
        if (exinfo!=null){
            TbUserExinfo tbUserExinfo=new TbUserExinfo();
            tbUserExinfo.setMineFollow(exinfo.isMineFollow());
            tbUserExinfo.setFollowMine(exinfo.isFollowMine());
            tbUserExinfo.setMineFollows(exinfo.getMineFollows());
            tbUserExinfo.setFollowMines(exinfo.getFollowMines());
            tbUserExinfo.setRegDays(exinfo.getRegDays());
            tbUserExinfo.setMessages(exinfo.getMessages());
            tbUserExinfo.setReplies(exinfo.getReplies());
            tbUserExinfo.setLogo(exinfo.getLogo());
            info.setExinfo(tbUserExinfo);
        }



        return info;
    }
}
